home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: mcv@pi.net (Miguel Carrasquer Vidal)
- Newsgroups: comp.lang.c.moderated,comp.lang.c
- Subject: Re: HELP IN WRITING MY FIRST PROGRAM ASSINGMENT
- Date: 21 Feb 1996 17:58:01 -0600
- Organization: Planet Internet
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4ggbi9$83k@solutions.solon.com>
- References: <3127dd4f.19010083@news.planet.net> <3127FF7A.6442C3B8@eden.com> <4gfhkj$3p8@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- seebs@solutions.solon.com (Peter Seebach) wrote:
-
- > [you know what you coded]
- >
- >$ sorter < foo
- > 1 2 3 4 5 6 7 8 9 10
- > 11 12 13 14 15 16 17 18 19 20
- > 21 22 23 24 25 26 27 28 29 30
- > 31 32 33 34 35 36 37 38 39 40
- > 41 42 43 44 45 46 47 48 49 50
- > 51 52 53 54 55 56 57 58 59 60
- > 61 62 63 64 65 66 67 68 69 70
- > 71 72 73 74 75 76 77 78 79 80
- > 81 82 83 84 85 86 87 88 89 90
- > 91 92 93 94 95 96 97 98 99 100
-
- > [...]
- >
- >Folks: If there appear to be mistakes in this code, *email me before posting*.
-
- Well I'm posting anyway :-)
- [you may put c.l.c back in the header if you like]
-
- I tried it (using Borland C 4.5 large model), and it didn't work.
-
- Output:
-
- 50 1 75 94 97 88 35 52 76 4
- 34 6 53 7 5 54 77 8 67 11
- 10 89 55 56 78 12 9 14 57 15
- 13 58 79 16 33 96 98 92 3 68
- 84 36 2 38 69 39 37 70 85 40
- 51 26 63 27 25 82 91 64 24 65
- 29 30 28 83 31 66 62 43 42 93
- 71 72 86 44 41 20 60 21 80 22
- 61 23 90 46 73 47 45 18 59 19
- 17 74 87 81 95 48 32 49 99 100
-
-
- I even recompiled the library function qsort with all references to
- "near pascal Exchange()" exchanged to "extern swap()", still no go...
-
-
- I wonder what my qsort() is doing wrong?
-
- [Of course it works if I do:
-
- /* compiler insisted I use `const' here... */
- int cmp(const void *a, const void *b) {
- if (*(int *)a < *(int *)b) return -1;
- if (*(int *)a > *(int *)b) return 1;
- else return 0;
- }
-
- and never touch swap(), but that's not nearly as much fun...]
-
-
- [but the whole point was that, sorting an array by address is legal, but
- does nothing. cmp was *intentionally* lying through its teeth, so
- qsort would be a noop. swap(), as correctly pointed out, is never
- called... It was in there because I was going to use my own quicksort,
- before I realized the stdlib one would work. -mod]
-
- ==
- Miguel Carrasquer Vidal ~ ~
- Amsterdam _____________ ~ ~
- mcv@pi.net |_____________|||
-
- ========================== Ce .sig n'est pas une .cig
-